<?php 
    session_start();
    include_once("libs/connectDB.php");
    include_once("libs/libs.php"); 
    
    if(isset($_POST['btnLogin'])) {
        $vUsername = isset($_POST['username']) ? $_POST['username'] : '';
        $vPassword = isset($_POST['password']) ? $_POST['password'] : '';
    
        login($vUsername, $vPassword);
    }
    
    if (isset($_GET['logout'])) {
        logout();
        header("Location: index.php");
    }
?>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="content-type" content="text/html" />
	<meta name="author" content="viet-coder.com" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Home</title>
</head>

<body>

    <div id="wrapper">
        
        <div id="header">
            <?php include_once("includes/header.inc"); ?>
        </div>
        
        <div id="menu">
            <?php include_once("includes/menu.inc"); ?>
        </div>
        
        <div id="main">
        
            <div id="content">
            <?php 
                $vMod = isset($_GET['mod']) ? $_GET['mod'] : '';
                $vFileModeInclude = '';
                switch ($vMod) {
                   case '':
                   {
                        $vFileModeInclude = "modules/frontpage.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Trang chủ";
                            include_once("modules/file_not_found.module.php");
                        }
                   }
                   break;
                   case 'culture':
                   {
                        $vFileModeInclude = "modules/culture.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Văn hóa";
                            include_once("modules/file_not_found.module.php");
                        }    
                   }
                   break;
                   case 'social':
                   {
                        $vFileModeInclude = "modules/social.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Xã hội";
                            include_once("modules/file_not_found.module.php");
                        }  
                   }
                   break;
                   case 'sport':
                   {
                        $vFileModeInclude = "modules/sport.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Thể thao";
                            include_once("modules/file_not_found.module.php");
                        }  
                   }
                   break;
                   case 'world':
                   {
                        $vFileModeInclude = "modules/world.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Thế giới";
                            include_once("modules/file_not_found.module.php");
                        }
                   }
                   break;
                   case 'news':
                   {
                        $vFileModeInclude = "modules/news.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Tin tức";
                            include_once("modules/file_not_found.module.php");
                        }
                   }
                   break;
                   case 'about':
                   {
                        $vFileModeInclude = "modules/about.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Giới thiệu";
                            include_once("modules/file_not_found.module.php");
                        }
                   }
                   break;
                   case 'news_category':
                   {
                        $vFileModeInclude = "modules/news_category.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Thể loại tin tức";
                            include_once("modules/file_not_found.module.php");
                        }
                   }
                   break;
                   case 'users':
                   {
                        $vFileModeInclude = "modules/users.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Người dùng";
                            include_once("modules/file_not_found.module.php");
                        }
                   }
                   break;
                   case 'register':
                   {
                        $vFileModeInclude = "modules/register.module.php";
                        if (file_exists($vFileModeInclude)) {
                            include_once($vFileModeInclude);
                        }
                        else
                        {
                            $vModuleName = "Đăng kí người dùng";
                            include_once("modules/file_not_found.module.php");
                        }
                   }
                   break;
                }
             ?>
            </div>
            <div id="sidebar">
            <?php include_once("includes/sidebar.inc") ?>
            sidebar</div>
        
        </div>
        
        <div id="footer">
            <?php //include_once("include/footer.inc"); ?>
        </div>
    
    </div>

</body>
</html>